<!-- /*
 * @Author: 谢力 843926058@qq.com
 * @Date:   2019-11-06
 * @Last Modified by:   谢力
 * @Last Modified time: 2019-11-07
 */ -->
<template>
    <div class="flex1 flex-row align-center middle-content relative">
        <span class="icon">
            <bsx-loading
                master-background="rgba(0,0,0,0)"
                box-background="rgba(0,0,0,0)"
                color="#9b9b9b"
                :size="35"
                :show-text="false">
            </bsx-loading>
        </span>
        <span>正在进入系统,请稍后...</span>
    </div>
</template>
<script>
import mixinCommon from './mixins/common';
import loginData from '@/assets/data/login';
// 路由引入
import menuData from '@/assets/data/menu';
export default {
    name: "miniProgramJump",
    data(){
        return {
        };
    },
    mixins:[
        mixinCommon
    ],
    computed:{
    },
    watch:{
    },
    created(){
        this.getInfo();
    },
    mounted(){
    },
    methods:{
        getInfo(){
            // this.showMessage('页面跳转').then(()=>{
                var result=loginData.returnData;
                this.setLoginStatus({
                    status:true,
                    token:`${result.token_type} ${result.access_token}`,
                    expires:result.token_expires_time
                });
                this.getMenuList().then(()=>{
                    this.setUserInfo(result.userInfo);
                    this.$root.$children[0].$children[0].refresh(()=>{
                        this.go();
                    });
                }).catch(({msg})=>{
                    this.showMessage(msg);
                });
            // });
        },
        //获取菜单
        getMenuList(){
            return new Promise((resolve,reject)=>{
                let result=menuData.returnData;
                this.setMenuList(result.list);
                resolve(result.list);
            });
        },
        go(){
            var jump_type=this.dictionary.jumpUrl[this.$route.query.sence.split('$')[0]].type;
            var jump_url=this.dictionary.jumpUrl
            var queryObj={};
            var senceArr=this.$route.query.sence.split('$');
            if(jump_type=='open'){
                if(senceArr&&senceArr.length>1){
                    window.location.href=this.dictionary.jumpUrl[this.$route.query.sence.split('$')[0]].path+'?sence='+this.$route.query.sence;
                }else{
                    window.location.href=this.dictionary.jumpUrl[this.$route.query.sence.split('$')[0]].path;
                }   
            } else {
                if(senceArr&&senceArr.length>1){
                    for (let i=1;i<senceArr.length;i++) {
                        queryObj[jump_url[senceArr[0]].key[i-1]]=senceArr[i]; 
                    }
                }
                this.$router.replace({
                    path:this.dictionary.jumpUrl[this.$route.query.sence.split('$')[0]].path,
                    query:queryObj
                });
            }
        },
    },
    components:{
    },
    beforeDestroy(){
    }
}
</script>
<style lang="less">
.middle-content{
    color:#9b9b9b;
    font-size:16px;
    line-height:20px;
    .icon{
        width:20px;
        height:20px;
        position:relative;
        margin-right:5px;
    }
}
</style>
